package com.leyou.gateway.config;

import com.leyou.common.auth.utils.RsaUtils;
import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.security.PrivateKey;
import java.security.PublicKey;

@Data
@ConfigurationProperties(prefix = "ly.jwt")
public class JwtProperties implements InitializingBean {
    private String pubKeyPath;//: F:\itcast-work\heima-tianjin-2\ssh\id_rsa.pub # 公钥地址

    private PublicKey publicKey;

    private UserToken userToken = new UserToken();

    @Data
    public class UserToken{
        private String cookieName;//:;// LY_TOKEN # cookie名称
    }

    /**
     * 使用springbean的生命周期
     * @throws Exception
     */
    @Override
    public void afterPropertiesSet() throws Exception {
        publicKey  = RsaUtils.getPublicKey(pubKeyPath);
    }
}
